package com.woniuxy.controller;

import com.woniuxy.entity.PaperAttribute;
import com.woniuxy.entity.PaperObject;
import com.woniuxy.entity.Question;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.impl.PaperServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @author:deng
 * @time:2022/4/26 17:24
 * @描述：试卷controller
 */
@Api(tags="试卷管理")
@RestController
    @RequestMapping("/paperManager")
public class PaperController {


    @Autowired
    PaperServiceImpl paperService;
    /*设置试卷基本信息*/
    @ApiOperation("设置试卷基本信息")
    @PostMapping("/paper")
    public ResponseEntity addPaperAttribute(@RequestBody PaperAttribute paperAttribute){
        return paperService.addPaperAttribute(paperAttribute);
    }
    /*根据类目分类id查询对应的题目 如选择题、填空题*/
    @ApiOperation("根据类目分类id查询对应的题目")
    @GetMapping("/paper/{questionId}")
    public ResponseEntity findQuestion(@PathVariable int questionId){
        return paperService.findQuestion(questionId);
    }
    @ApiOperation("模糊查询题目")
    @GetMapping("/paper2/{questionId}")
    public ResponseEntity findAllQuestionBytitle(@PathVariable int questionId,String title){
        return paperService.findAllQuestionBytitle(questionId,title);

    }

    /*添加题目到试卷*/
    @ApiOperation("添加到试卷列表")
    @PostMapping("/paper1")
    public ResponseEntity addPaper(@RequestBody Question question){

        return paperService.addPaper(question.getQuesstionIds());

    }
    /*查询组装试卷*/
    @ApiOperation("查询组装好的试卷")
    @GetMapping("/paper1/{paperId}")
    public ResponseEntity findAllTopic(@PathVariable int paperId){
        return paperService.findAllTopic(paperId);
    }

    /*删除试卷*/
    @ApiOperation("取消生成试卷")
    @DeleteMapping("/paper1")
    public ResponseEntity deleteTopic(){
        return paperService.deleteTopic();
    }
    /*查询新添加的试卷的id*/
    @ApiOperation("查询生成试卷id")
    @GetMapping("/paper")
    public ResponseEntity findAddPaperId(){
        return paperService.findAddPaperId();
    }
    /*删除试卷*/
    @ApiOperation("批量删除试题")
    @DeleteMapping("/paper")
    public ResponseEntity deleteTopicList(@RequestBody PaperObject paperObject){

        return paperService.deleteTopicList(paperObject);
    }
    /*设置题目分数*/
    @ApiOperation("设置题的分数")
    @PutMapping("/paperScore")
    public ResponseEntity updateTopic(@RequestBody PaperObject paperObject) {
        System.out.println("getScoreList是"+paperObject.getScoreList());
        /*通过试卷id 以及题目类型，以及score来设置分数*/
        return paperService.updateTopic(paperObject);

    }

}
